/*
 * DTOCliente.cpp
 *
 *  Created on: Oct 23, 2011
 *      Author: gonzalo
 */

#include "DTOCliente.h"

DTOCliente::DTOCliente(std::string& aDeserealizar,std::string owner): DTO(CLIENTE,owner) {
	deserializar(aDeserealizar,owner);
}

DTOCliente::DTOCliente(std::string id,ClientStatus status,DTOShipStatus* shipStatus) : DTO(CLIENTE,id){
	this->status = status;
	this->ship = shipStatus;
}

DTOCliente::~DTOCliente() {
}

std::string DTOCliente::serializar(){
	std::stringstream retorno;
	retorno << UtilString::TOlenghtStringStringValue(this->status);
	if (this->ship != NULL) {
		retorno << this->ship->serializar();
	}

	return retorno.str();
}
void DTOCliente::deserializar(std::string& string,std::string owner){
	this->status = (ClientStatus)(UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string)));

	if(string.size() > 0){
		this->ship = new DTOShipStatus(string,owner);
	}
}

DTOShipStatus *DTOCliente::getShip() const
{
    return ship;
}

ClientStatus DTOCliente::getStatus() const
{
    return status;
}

void DTOCliente::setStatus(ClientStatus clientStatus){
	status = clientStatus;
}



